<?php
// +---------------------------------------------------------------------------+
// | This file is part of the KnowledgebasePublisher package                   |
// | KnowledgebasePublisher - web based knowledgebase publisher tool           |
// |                                                                           |
// | Author:  Evgeny Leontev <eleontev@gmail.com>                              |
// | Copyright (c) 2005 Evgeny Leontev                                         |
// |                                                                           |
// | For the full copyright and license information, please view the LICENSE   |
// | file that was distributed with this source code.                          |
// +---------------------------------------------------------------------------+


class KBClientView_rssfeed extends KBClientView_common
{

	function &execute(&$manager) {
		
		$this->home_link = true;
		$this->meta_title = &$this->msg['rss_title_msg'];
		//$this->meta_keywords = &$row['meta_keywords'];
		//$this->meta_description = &$row['meta_description'];

		$data = $this->getTop($manager, $this->meta_title);
		$data .= $this->getList($manager);
		
		return $data;		
	}
	
	
	function getList(&$manager)  {
		
		$tpl = &new tplTemplatez($this->template_dir . 'rss_list.html');
		
		$rss_title = $manager->getSetting('rss_title');
		$rss_description = $manager->getSetting('rss_description');
		$rss_file = $this->controller->kb_path . 'rss.php';

		$rows = array();
		$rows[0]['title'] = $rss_title;
		$rows[0]['description'] = $rss_description;
		$rows[0]['rss_link'] = $rss_file;
		
		// top
		if($manager->getSetting('rss_generate') == 'top') {
			
			$categories = $manager->getCategoryRssData();
			
			foreach($categories as $category_id => $v) {
				$rows[$category_id]['title'] = sprintf('%s', $v['title']);
				$rows[$category_id]['description'] = sprintf('%s', $v['description']);
				$rows[$category_id]['rss_link'] = $rss_file . '?c=' . $category_id;
				
				unset($categories[$category_id]);
			}
		}
		
		$rows = &$this->stripVars($rows);
		
		foreach($rows as $k => $v) {
			$v['kb_path'] = $this->controller->client_path;
			//$v['row_class'] = $this->getRowClass();
			$tpl->tplParse($v, 'row');
		}
		
		$tpl->tplAssign('title_msg', $this->msg['rss_title_msg']);
		$tpl->tplParse();
		return $tpl->tplPrint(1);
	}
}
?>